#ifndef HDDELEGATE_H
#define HDDELEGATE_H

#include "DeckLinkAPI.h"

class HDDelegate : public IDeckLinkInputCallback
{
public:
    HDDelegate();
    ~HDDelegate();

    virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
    virtual ULONG STDMETHODCALLTYPE AddRef(void);
    virtual ULONG STDMETHODCALLTYPE  Release(void);
    virtual HRESULT STDMETHODCALLTYPE VideoInputFormatChanged(BMDVideoInputFormatChangedEvents, IDeckLinkDisplayMode*, BMDDetectedVideoInputFormatFlags);
    virtual HRESULT STDMETHODCALLTYPE VideoInputFrameArrived(IDeckLinkVideoInputFrame*, IDeckLinkAudioInputPacket*);

private:
    ULONG				m_refCount;
    pthread_mutex_t		m_mutex;


    int								videoOutputFile = -1;
    int								audioOutputFile = -1;

    IDeckLink 						*deckLink;
    IDeckLinkInput					*deckLinkInput;
    IDeckLinkDisplayModeIterator	*displayModeIterator;

    static BMDTimecodeFormat		g_timecodeFormat = 0;
    static int						g_videoModeIndex = -1;
    static int						g_audioChannels = 2;
    static int						g_audioSampleDepth = 16;
    const char *					g_videoOutputFile = NULL;
    const char *					g_audioOutputFile = NULL;
    static int						g_maxFrames = -1;

    static unsigned long 			frameCount = 0;
};

#endif // HDDELEGATE_H
